// 固定写法

// 引入常量
import {
    // RECEIVE_CATEGORY,
    RECEIVE_USER_INFO,
    RECEIVE_USER_STATUS,
    RECEIVE_COUPON,
    RECEIVE_COLLECT_LIST,
    RECEIVE_ADDRESS_LIST,
    RESET_USER_INFO,
} from './mutation-types'

export default {
    // [RECEIVE_CATEGORY](state,{category}){ //{categroy}是actions传来的数据
    //     state.category = category  //更新state里的数据
    // },
    [RECEIVE_USER_INFO](state,{userInfo}){ 
        state.userInfo = userInfo  
    },
    [RECEIVE_USER_STATUS](state,{flag}){ 
        state.isLogin = flag
    },
    [RECEIVE_COUPON](state,{coupon,code}){ 
        if(code == 1){
            state.unusedCoupon = coupon
        }
        if(code == 2){
            state.usedCoupon = coupon
        }
    },
    [RECEIVE_COLLECT_LIST](state,{collectList}){
        state.collectList = collectList
    },
    [RECEIVE_ADDRESS_LIST](state,{addressList}){
        state.addressList = addressList
    },
    [RESET_USER_INFO](state) {
        state.userInfo = {}
    }
}